'''
https://www.runoob.com/w3cnote/ten-sorting-algorithm.html
1.快速排序
2.插入排序
'''
import numpy as np
def swap(data, num1, num2):
    a = data[num1]
    data[num1] = data[num2]
    data[num2] = a
def getMin(data, start):
    i = start
    min = data[i]
    minIdex = i
    while i < len(data):
        print(f'i={i}, data[i]={data[i]}, min={min},minIndex={minIdex}')
        if min > data[i]:
            print(i)
            minIdex = i
            min=data[minIdex]
        i = i + 1
    return minIdex
def sort(data):
    q = 0
    while q < len(data):
        l = getMin(data, q)
        print(f'l={l}, q={q}')
        swap(data, q, l)
        print(data)
        q = q + 1
    return data
data = np.random.randint(1, 100, size=5)
print(data)
print('最终结果', sort(data))